#ifndef _SERVER_
#define _SERVER_
#include <my_header.h>
#include "tidArr.h"
#include "taskQueue.h"
#include "transFile.h"
#include "directory.h"
#include "login.h"
#include "usrinfo.h"
#include <l8w8jwt/encode.h>
#include <l8w8jwt/decode.h>
#include "token.h"
#include "bitmap.h"
#define THRESHOLD 104857600

enum{
    CD,
    LS,
    PWD,
    MKDIR,
    RMDIR,
    GETS,
    PUTS,
    FILENAME,
    FILESIZE,
    FILEDATA,
    FILEEND,
    REMOVE,
    QUIT,
    LOGIN,
    USRNAME,
    ENCRYPTED,
    QUERY,
    TOKEN
};

typedef struct threadPool_s {
    //子线程信息
    tidArr_t tidArr;
    //任务队列
    taskQueue_t taskQueue;
    //锁
    pthread_mutex_t mutex;
    //条件变量
    pthread_cond_t cond;
    //用户信息
    usrinfo_t usrinfo;
    //退出标志
    int exitFlag;
}threadPool_t;

int threadPoolInit(threadPool_t* threadPool, int workerNum);

int makeWorker(threadPool_t* threadPool);

int initTCP(char* ip, char* port);

int epollAdd(int epfd, int netfd);

int epollDel(int epfd, int netfd);

#define LOG_ERROR_CHECK(ret,error_flag,msg) \
    do{\
        if((ret) == (error_flag)) {\
            syslog(LOG_INFO,msg);\
        }\
    }while(0)

#endif
